home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Treccani Italiana Di Scienze Lettere Ed Arti
/
[Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso
/
pc
/
data
/
xxi_appendice_dvd.swf
/
scripts
/
__Packages
/
CScrollableMenu.as
< prev
next >
Wrap
Text File
|
2007-11-08
|
6KB
|
146 lines
class CScrollableMenu extends mx.core.UIObject
{
function CScrollableMenu()
{
super();
this.mMaxItemNumber = 5;
this.mRowHeigth = 26;
this.mWidth = this._width;
this.mRect = new Object({left:this._x,top:this._y,right:this._x + this._width,bottom:this._y + this._height});
this.mType = "pullDown";
this.mShowGrabRect = false;
this._xscale = this._yscale = 100;
this.Hide();
this.doLater(this,"init");
}
function init()
{
this.mc_Background._x = 0;
this.mc_Background._y = 0;
this.mc_Background._height = this.mRowHeigth;
this.SetWidth(this.mWidth);
this.mc_MenuListbox.__set__rowHeight(this.mRowHeigth);
this.mc_MenuListbox.setStyle("borderStyle","none");
this.mc_MenuListbox.setStyle("borderColor",12566711);
this.mc_MenuListbox.embedFonts = _global.gUseEmbeddedFont;
this.mc_MenuListbox.setStyle("backgroundColor",7174258);
this.mc_MenuListbox.setStyle("rollOverColor",10398115);
this.mc_MenuListbox.setStyle("selectionColor",9477012);
this.mc_MenuListbox.setStyle("color",16777215);
this.mc_MenuListbox.setStyle("textRollOverColor",16777215);
this.mc_MenuListbox.setStyle("textSelectedColor",16777215);
this.mc_MenuListbox.addEventListener("change",mx.utils.Delegate.create(this,this.onItemSelected));
this.mc_ButtonUp.addEventListener("click",mx.utils.Delegate.create(this,this.onScrollUp));
this.mc_ButtonDown.addEventListener("click",mx.utils.Delegate.create(this,this.onScrollDown));
this.mc_GrabRect.onPress = mx.utils.Delegate.create(this,this.Hide);
this.mc_MenuListbox.__set__vScrollPolicy("off");
}
function SetWidth(inW)
{
this.mWidth = inW;
this.mc_Background._width = this.mWidth;
this.mc_ButtonUp.setSize(this.mWidth,this.mRowHeigth - 1);
this.mc_ButtonDown.setSize(this.mWidth,this.mRowHeigth - 1);
this.mc_MenuListbox.setSize(this.mWidth,this.mRowHeigth);
}
function setIconFunction(inFunction)
{
this.mc_MenuListbox.setIconFunction(inFunction);
}
function setCellRenderer(inRenderer, embeddedFont)
{
this.mc_MenuListbox.embedFonts = embeddedFont;
this.mc_MenuListbox.setCellRenderer(inRenderer);
}
function onScrollUp(evtObj)
{
var _loc2_ = this.mc_MenuListbox.__get__vPosition() - 1;
this.mc_MenuListbox.__set__vPosition(_loc2_);
this.mc_ButtonUp.enabled = _loc2_ > 0;
this.mc_ButtonDown.enabled = _loc2_ < this.mc_MenuListbox.length - this.mc_MenuListbox.__get__rowCount();
}
function onScrollDown(evtObj)
{
var _loc2_ = this.mc_MenuListbox.__get__vPosition() + 1;
this.mc_MenuListbox.__set__vPosition(_loc2_);
this.mc_ButtonUp.enabled = _loc2_ > 0;
this.mc_ButtonDown.enabled = _loc2_ < this.mc_MenuListbox.length - this.mc_MenuListbox.__get__rowCount();
}
function onItemSelected(evtObj)
{
this.Hide();
var _loc2_ = evtObj.target;
var _loc3_ = _loc2_.dataProvider.getItemAt(_loc2_.selectedIndex);
this.dispatchEvent({type:"scrollableMenuItemSelected",target:this,data:_loc3_,selectedItemIndex:_loc2_.selectedIndex});
}
function Show(inRecordset, inSelected)
{
var _loc3_ = Math.min(inRecordset.length,this.mMaxItemNumber);
this.mc_MenuListbox.__set__rowCount(_loc3_);
this.mc_MenuListbox.dataProvider = inRecordset;
if(inRecordset.length > this.mMaxItemNumber)
{
this.mc_ButtonUp._y = 1;
this.mc_MenuListbox._y = this.mc_ButtonUp._y + this.mc_ButtonUp.__get__height();
this.mc_ButtonDown._y = this.mc_MenuListbox._y + this.mc_MenuListbox.__get__height() + 1;
this.mc_Background._height = this.mc_ButtonDown._y + this.mc_ButtonDown.__get__height() + 1;
this.mc_ButtonUp._visible = true;
this.mc_ButtonDown._visible = true;
this.mc_ButtonUp.enabled = false;
this.mc_ButtonDown.enabled = true;
}
else
{
this.mc_Background._height = this.mc_MenuListbox.__get__height() + 1;
this.mc_ButtonUp._visible = false;
this.mc_ButtonDown._visible = false;
this.mc_MenuListbox._y = 0;
}
if(inSelected >= 0)
{
this.mc_MenuListbox.selectedIndex = inSelected;
}
if(this.mType == "pullDown")
{
this._y = this.mRect.top;
}
else
{
this._y = this.mRect.bottom - this.mc_Background._height;
}
this.mc_Background._visible = true;
this.mc_MenuListbox._visible = true;
if(this.mShowGrabRect)
{
this.InitGrabRect(this.mc_GrabRect);
this.mc_GrabRect._visible = true;
}
this._visible = true;
}
function Hide()
{
this.mc_GrabRect._visible = false;
this.mc_ButtonUp._visible = false;
this.mc_ButtonDown._visible = false;
this.mc_MenuListbox._visible = false;
this.mc_Background._visible = false;
this._visible = false;
}
function ReleaseMemory()
{
this.Hide();
}
function InitGrabRect(inClip)
{
var _loc2_ = {x:0,y:0};
inClip._xscale = inClip._yscale = 100;
inClip._x = inClip._y = 0;
inClip.globalToLocal(_loc2_);
inClip._x = _loc2_.x;
inClip._y = _loc2_.y;
inClip._width = Stage.width;
inClip._height = Stage.height;
inClip.useHandCursor = false;
}
}